<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .yangshi {
            width: 100px;
            height: 100px;
            background: blue;
            float: left;
            border: 2px solid black;
            line-height: 100px;
            font-size: 25px;
            color: white;
            font-weight: bold;
            text-align: center;
            margin-left: 4px;
        }
    </style>
</head>

<body>
    <div class="yangshi"></div>
    <div class="yangshi"></div>
    <div class="yangshi"></div>
    <div class="yangshi"></div>
    <div class="yangshi"></div>
    <script>
        var yangshi = document.getElementsByClassName("yangshi");
        var mubiaoshijian = new Date("2021 1-1 00:00:00");
        var xuanyanfangfa = setInterval(function () {
            var xianzaishijian = new Date();
            var shijiancha = mubiaoshijian - xianzaishijian;
            var haomiaoshu = (shijiancha % 1000);
            var zongmiaoshu = Math.floor(shijiancha / 1000);
            var miaoshu = (zongmiaoshu % 60);
            var fenzhongshu = Math.floor(zongmiaoshu / 60) % 60;
            var xiaoshishu = Math.floor(zongmiaoshu / 3600) % 24;

            var tianshu = Math.floor(zongmiaoshu / 86400) % 365;
            yangshi[0].innerHTML = tianshu + '天';
            yangshi[1].innerHTML = xiaoshishu + '时';
            yangshi[2].innerHTML = fenzhongshu + '分';
            yangshi[3].innerHTML = miaoshu + '秒';
            var qwe = '';
            if (haomiaoshu < 10) {
                qwe = '00' + haomiaoshu;
            } else if (haomiaoshu >= 10 && haomiaoshu < 100) {
                qwe = '0' + haomiaoshu;

            } else {
                qwe = haomiaoshu;
            }
            yangshi[4].innerHTML = qwe + '毫秒';

        }, 1)

    </script>
</body>

</html>